package edu.gdkm.demo8;

import java.io.File;
import java.io.FileReader;
import java.io.IOException;

public class FileDemo3 {
    //修改程序，统计'人民'出现的次数
    public static void main(String[] args) throws IOException {
        File file = new File("./ershidabaogao.txt");
        FileReader fr = new FileReader(file);
        int count=0;
        String report="";
        while (true){
            int i=fr.read();
            if(i ==-1){
                break;
            }else{
                report+=(char)i;
            }
        }
        System.out.println(report);

        while(true){
            if(report.indexOf("人民")>0){
                count++;
                report=report.substring(report.indexOf("人民")+1);
            }else{
                break;
            }
        }

        System.out.println("报告中，'人民'一共出现了"+count+"次");
    }

}
